class Photo < ActiveRecord::Base
  require                     'RMagick'
  include                     Magick
  has_many                    :comments
  has_many                    :blog_posts
  belongs_to                  :show
  has_attachment              :storage =>       :file_system, 
                              :processor=>      :rmagick,
                              :content_type =>  :image,
                              :max_size =>      6000.kilobytes,
                              :thumbnails => {  :thumb =>   '100x100>',
                                                :small =>   '320x240',
                                                :screen =>  '640x480' }
  #for some reason I can't get validations to work here.
  #validates_presence_of       :caption
  #has_friendly_id             :caption,         :use_slug => true
  
  validates_as_attachment
  
  before_destroy              :delete_comments
  
  attr_accessible             :show, :caption  #not sure why this needs to be here... suspect a problem with restful_authentication, but hey, it works. 8/25/2009
  
protected
  def delete_comments
    self.comments.each {|comment| comment.destroy}
  end
end
